package net.csdn.business.mirror.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;

import java.util.Map;
import java.util.Objects;

public class ProjectMirrorEnum {

    /**
     * 镜像仓库状态枚举
     */
    @AllArgsConstructor
    public enum Status {

        /**
         * 初始化状态：用户刚导入数据，从未发送到云效那边执行。
         */
        _INIT(-1, "init", "初始化"),
        _0(0, "none", "导入中"),
        _1(1, "import_success", "导入成功"),
        _2(2, "started", "同步中"),
        _3(3, "finished", "同步完成"),
        _4(4, "failed", "同步失败"),
        _5(5, "stopped", "已暂停"), //此状态于20240717增加同步开关：isSync之后废弃
        _6(6, "scheduled", "待同步"),
        _7(7, "import_failed", "导入失败"),

        _99(99, "blacked", "已禁用"),
        ;
        public int code;
        private String desc;
        public String trans;

        public static final Map<Integer, ProjectMirrorEnum.Status> MAP = Maps.newHashMap();
        public static final Map<Integer, String> TRANS_MAP = Maps.newHashMap();

        static {
            for (ProjectMirrorEnum.Status status : ProjectMirrorEnum.Status.values()) {
                MAP.put(status.code, status);
                TRANS_MAP.put(status.code, status.trans);
            }
        }

        public static ProjectMirrorEnum.Status parse(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            return MAP.get(code);
        }
    }

    @AllArgsConstructor
    public enum UserType {
        _0(0, "admin"),
        _1(1, "user"),
        ;
        public int code;
        public String desc;
    }


    @AllArgsConstructor
    public enum SyncStatus {

        DISABLE(-1, "禁用"),
        CLOSE(0, "关闭"),
        OPEN(1, "开启"),
        ;
        public int code;
        public String desc;
    }
}
